import api from '../index'
import tools from '@/tools'
import config from "@/config"


// 查询task列表
export const listTask = (params) => {
	var userId = localStorage.getItem("userId")
	const url = `/vapi/activity/task/list?userid=` + userId
	return api.get(url, params)
}

// 查询task列表
export const listTaskAll = (params) => {
	const url = '/vapi/activity/task/listAll'
	return api.get(url, params)
}



// 查询表单
export const formDataShow = (id) => {
	var userId = localStorage.getItem("userId")
	// const url = '/vapi/activity/task/formDataShow/'+id+'?userid='+userId
	// const url = '/vapi/activity/task/formDataShow/' + id + '?userid=' + userId
	const url = `${config.pre}/activity/task/formDataShow/${id}?userid=${userId}`
	return api.get(url)
}

// 保存表单
export const formDataSave = (taskID, data) => {
	var userId = localStorage.getItem("userId")
	// const url = '/vapi/activity/task/formDataSave/'+taskID+'?userid='+userId
	const url = '/vapi/activity/task/formDataSave/v2/' + taskID + '?userid=' + userId
	return api.post(url, data)
}

// 保存表单
export const formDataSaveV3 = (taskID, data, nextUser) => {
	var userId = localStorage.getItem("userId")
	const url = `${config.pre}/activity/task/formDataSave/v3/${taskID}?nextUser=${nextUser}&userId=${userId}`
	return api.post(url, data)
}




// 根据部门ID查询是否需要审批
export const getApprove = (id) => {
	const url = '/vapi/activity/actorg/' + id
	return api.get(url)
}


// 根据用户ID查询部门ID
export const getApproveByUserId = (id) => {
	const url = '/vapi/activity/actorg/selectOrgByUserid/' + id
	return api.get(url)
}


// 修改是否需要审批
export const updateApprove = (data) => {
	const url = '/vapi/activity/actorg?type=' + data.type
	return api.put(url, data)
}


// 查看审批历史
export const getActivitiDetailByOrderId = (orderId) => {
	const url = '/vapi/activity/historyFromData/ByOrderId/' + orderId
	return api.get(url)
}

// 取消预占订单
export const cancelApply = (orderId) => {
	const url = '/vapi/activity/actleave/cancelApply/' + orderId
	return api.post(url)
}


// 获取商品价格变动折线图
export const getLine = (data) => {
	const url = '/dlzldb/goodsPriceRecord/getLine'
	return api.post(url, data)
}


//前台订单列表
export const getSysOrderList = (params) => {
	const url = '/vapi/activity/actorder/list'
	return api.get(url, params)
}

//前台查询我的待办数量
export const listnum = (params) => {
	var userId = localStorage.getItem("userId")
	const url = '/vapi/activity/task/listnum?userid=' + userId
	return api.get(url, params)
}

// 已办导出订单
export const dolistexcel = (params) => {
	params.createTime = '';
	var userId = localStorage.getItem("userId")
	const url = '/vapi/activity/task/dolistexcel/' + userId
	return api.get(url, params)
}

// 查询task列表
export const doListTask = (params) => {
	params.createTime = '';
	var userId = localStorage.getItem("userId")
	const url = '/vapi/activity/task/dolist/' + userId
	return api.get(url, params)
}

// 查询审批列表
export const getlist = () => {
	const url = '/activitis/getlist'
	return api.get(url)
}

export const nextTaskUser = (taskId) => {
	var userId = localStorage.getItem("userId")
	const url = `${config.pre}/activity/task/nextTaskUser?taskId=${taskId}&userId=${userId}`
	return api.get(url)
}
